import Vue from "vue";
import VueRouter from "vue-router";
// import { component } from "vue/types/umd";
// import Login from "@/views/login/Login.vue";
// import Main from "@/views/main/Main.vue";
Vue.use(VueRouter);

const routes = [
  {
    // 路由重定向
    path: "/",
    redirect: window.__POWERED_BY_QIANKUN__ ? "/micro" : "/main",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/Login.vue"),
  },
  {
    path: "/largeScreen",
    name: "largeScreen",
    component: () => import("@/views/largeScreen/largeScreenNew.vue"),
  },
  // 新版大屏适配页面
  {
    path: "/bigScreen",
    name: "bigScreen",
    component: () => import("@/views/bigScreen/index.vue"),
  },
  // 微应用模式下的路由配置 - 只渲染内容区域
  {
    path: "/micro",
    name: "micro",
    component: () => import("@/MicroApp.vue"),
    children: [
      {
        path: "",
        redirect: "/micro/home",
      },
      // 子路由 - 只渲染内容，不包含侧边栏和头部
      {
        path: "home",
        name: "MicroHome",
        component: () => import("@/views/home/Home.vue"),
      },
      // 用户管理
      {
        path: "user",
        name: "MicroUser",
        component: () => import("@/views/user/User.vue"),
      },
      // 商品管理
      {
        path: "mall",
        name: "MicroMall",
        component: () => import("@/views/mall/Mall.vue"),
      },
      // 图表页面
      {
        path: "chart",
        name: "MicroChart",
        component: () => import("@/views/Echart/index.vue"),
      },
      //3d地图
      {
        path: "map3d",
        name: "MicroMap3D",
        component: () => import("@/views/threeMap/threeMap.vue"),
      },
    ],
  },
  // 完整应用模式下的路由配置 - 包含侧边栏和头部
  {
    path: "/main",
    name: "main",
    component: () => import("../views/main/Main.vue"),
    children: [
      // 子路由
      {
        path: "home",
        component: () => import("../views/home/Home.vue"),
      },
      // 用户管理
      {
        path: "user",
        component: () => import("@/views/user/User.vue"),
      },
      // 商品管理
      {
        path: "mall",
        component: () => import("@/views/mall/Mall.vue"),
      },
      // 其他页面1
      {
        path: "page1",
        component: () => import("@/views/otherPage/PageOne.vue"),
      },
      // 其他页面2
      {
        path: "page2",
        component: () => import("@/views/otherPage/PageTwo.vue"),
      },
      // 其他页面2  分页练习
      // {
      //   path: "page3",
      //   component: () => import("@/views/otherPage/PageTest.vue"),
      // },
      {
        path: "page4",
        component: () => import("@/views/otherPage/ComponentTest.vue"),
      },
      // 图表页面
      {
        path: "chart",
        component: () => import("@/views/Echart/index.vue"),
      },
      //3d地图
      {
        path: "map3d",
        component: () => import("@/views/threeMap/threeMap.vue"),
      },
    ],
  },
  {
    path: "/:pathMatch(.*)",
    component: () => import("@/views/notFound/NotFound.vue"),
  },
];

const router = new VueRouter({
  mode: window.__POWERED_BY_QIANKUN__ ? "abstract" : "history",
  base: window.__POWERED_BY_QIANKUN__ ? "/" : "/",
  routes,
});

export default router;
